package service.statistics.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import service.edu.result.R;
import service.statistics.client.UcenterClient;
import service.statistics.entity.Counter;
import service.statistics.entity.vo.CounterVo;
import service.statistics.service.CounterService;

import java.util.HashMap;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author diao
 * @since 2020-09-23
 */
@RestController
@RequestMapping("/statistics/counter")
@CrossOrigin
public class CounterController {
    @Autowired
    private CounterService  counterService;


    @ApiOperation("统计某一天注册的会员数并注入数据库中,如果重复则更新")
    @PostMapping("/countDailyRegister/{date}")
    public R countRegisterMembers(@PathVariable String date){
              counterService.countData(date);
        return  R.Ok();
    }

    @ApiOperation("根据条件返回统计数据")
    @PostMapping("/getData")
    public R getData(@RequestBody CounterVo counter){
        HashMap<String,Object> map =counterService.getData(counter);
        return R.Ok().data(map);
    }
}

